﻿<%@ Page EnableEventValidation="false" Language="C#" AutoEventWireup="true" CodeBehind="EditLocation.aspx.cs" Inherits="DLV.BackEnd.Pages.EditLocation" %>
<%@ Register Src="~/Controls/TinyMCE.ascx" TagPrefix="uc1" TagName="TinyMCE" %>

<asp:content id="Content1" contentplaceholderid="placeHolderContent" runat="server">
    <div id="toolbar-box">
		<div class="t">
			<div class="t">
				<div class="t"></div>
			</div>
		</div>
		<div class="m">
		    <div id="toolbar" class="toolbar">
			    <table class="toolbar">
			        <tbody>
					    <tr>
						    <td id="toolbar-save" class="button">
						        <asp:LinkButton ID="lbtSave" runat="server" Text="" onclick="lbtSave_Click" CssClass="toolbar">
					                <span id="Span1" title="Save" class="icon-32-save" runat="server"></span>Lưu
					            </asp:LinkButton>
						    </td>
						    <td id="toolbar-cancel" class="button">
						        <asp:LinkButton ID="lbtClose" runat="server" Text="" onclick="lbtClose_Click" 
                                    CssClass="toolbar" CausesValidation="False">
					                <span id="Span2" title="Close" class="icon-32-cancel" runat="server"></span>Thoát
					            </asp:LinkButton>
						    </td>
					    </tr>
				    </tbody>
			    </table>
		    </div>
			<div class="header">Thêm mới/chỉnh sửa địa điểm</div>
			<div class="clr"></div>
		</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
	</div>
	<div id="element-box">
		<div class="t">
			<div class="t">
				<div class="t"></div>
			</div>
		</div>
		<div class="m" style="float:left; width:100%">
			<div class="admin-left">
                <table class="adminform">
                    <tr>
						<td colspan="2">
                            <div id="ErorMessage" style="color: Red;line-height: 150%;"></div>
                        </td>
					</tr>
                    <tr>
                        <td style="width: 20%;">Tên địa điểm:</td>
                        <td><asp:TextBox id="txtLocationName" runat="server" Width="97%"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td>Loại:</td>
                        <td>
                            <asp:DropDownList ID="ddlLocationType" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr class="location-code" style="display: none;">
                        <td style="width: 20%;">Mã địa điểm:</td>
                        <td><asp:TextBox id="txtCode" runat="server" Width="97%"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            Mô tả chi tiết
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <uc1:TinyMCE runat="server" ID="txtContent" />
                        </td>
                    </tr>
                </table>  
            </div>  
            <div class="admin-right">
                <table class="adminform">
                    
                    <tr>
                        <td>Châu lục</td>
                        <td>
                            <asp:DropDownList ID="ddlContinent" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>Quốc gia</td>
                        <td>
                            <asp:DropDownList ID="ddlNational" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>Tỉnh/Thành phố</td>
                        <td>
                            <asp:DropDownList ID="ddlCity" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>Quận/Huyện</td>
                        <td>
                            <asp:DropDownList ID="ddlDistrict" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>Phường/Xã</td>
                        <td>
                            <asp:DropDownList ID="ddlWard" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>Số nhà, đường: </td>
                        <td>
                            <asp:TextBox ID="txtAddress" runat="server" Width="400px" />
                        </td>
                    </tr>
                    <tr>
                        <td>Mô tả ngắn</td>
                        <td>
                            <asp:TextBox ID="txtSortDescription" TextMode="MultiLine" runat="server" Width="400px" Height="100px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>Tình trạng</td>
                        <td>
                            <asp:DropDownList ID="ddlStatus" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>Người tạo</td>
                        <td>
                            <asp:DropDownList ID="ddlAdminUser" runat="server" Width="200px"></asp:DropDownList>
                        </td>
                    </tr>
                    
                </table>
            </div>
            <div class="clr"></div>
		</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
	</div>
    
    <!-- Load National, City, District, Ward -->
    <script src="/js/jquery.address.js"></script>
    <script type="text/javascript">
        var continentItem = $('#<%=ddlContinent.ClientID %>');
        var nationalItem = $('#<%=ddlNational.ClientID %>');
        var cityItem = $('#<%=ddlCity.ClientID %>');
        var districtItem = $('#<%=ddlDistrict.ClientID %>');
        var wardItem = $('#<%=ddlWard.ClientID %>');
        loadNational(continentItem, nationalItem, cityItem, districtItem, wardItem);
        loadCity(nationalItem, cityItem, districtItem, wardItem);
        loadDistrict(cityItem, districtItem, wardItem);
        loadWard(districtItem, wardItem);
    </script>
    
    <!-- Validate -->
    <script type="text/javascript">
        $(document).ready(function () {
            var showHideLocationCodeField = function(locationTypeId) {
                if (locationTypeId == 1)
                    $('.location-code').show();
                else {
                    $('.location-code').hide();
                }
            };

            var id = $('#<%=ddlLocationType.ClientID %> option:selected').val();
            showHideLocationCodeField(id);

            $('#<%=ddlLocationType.ClientID %>').change(function() {
                var idLocationType = $('#<%=ddlLocationType.ClientID %> option:selected').val();
                showHideLocationCodeField(idLocationType);
            });

            $("#<%= lbtSave.ClientID %>").click(function () {
                $("#ErorMessage").html('');

                var rtnValue = validate($("#<%= txtLocationName.ClientID %>"), $("#ErorMessage"), "Vui lòng nhập tên menu<br\>")
                    && validate($("#<%= txtSortDescription.ClientID %>"), $("#ErorMessage"), "Vui lòng nhập mô tả ngắn<br\>");

                return rtnValue;
            });
        });
    </script>
</asp:content>